package com.yunji.order.emuns;

import com.yunji.common.utils.bean.BeanUtils;
import lombok.Getter;

import java.util.Objects;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.order.emuns
 * @Title: PayTypes
 * @Description: 支付类型
 * <p>
 * History:
 * Date                     Version     Author          Summary
 * ============================================================
 * 2024-04-10 15:23:22      V1.0        HuaAo       新建类
 */
@Getter
public enum PayTypes {
    NOT_EXISTS(-1, "无"),
    REVENUE(1, "收入"),
    CONSUME(0, "支出");
    private final Integer code;
    private final String text;

    PayTypes(Integer code, String text) {
        this.code = code;
        this.text = text;
    }

    public static String getText(Integer code) {
        if (BeanUtils.isNull(code)) {
            return null;
        }
        PayTypes[] enums = PayTypes.values();
        for (PayTypes e : enums) {
            if (Objects.equals(e.code, code)) {
                return e.text;
            }
        }
        return PayTypes.NOT_EXISTS.getText();
    }
}
